
#ifndef __SAFEWALL_ENCRYPT_H__
#define __SAFEWALL_ENCRYPT_H__
#include "../SafeWall.h"


#ifdef __cplusplus
extern "C" {
#endif
	int InlineIsEqualSWID(const SWID* swid1, const SWID* swid2);
	BOOLEAN InitSafeWallObject(LPSAFEWALL_OBJECT* lpSafeWall);
	NTSTATUS SetSafeWallToFileHead(IN LPSAFEWALL_OBJECT safewall, IN HANDLE FileHandle,
		IN PFILE_OBJECT FileObject, IN PDEVICE_OBJECT DeviceObject);
	DWORD CheckSafeWallFlags(LPSAFEWALL_OBJECT SafeWall);

	NTSTATUS SafeWallEncryptFile(PUNICODE_STRING srcFilePath, PDEVICE_OBJECT DeviceObject);
	NTSTATUS SafeWallDecryptFile(PUNICODE_STRING srcFilePath, PDEVICE_OBJECT DeviceObject);

	void Dehead(LPSAFEWALL_OBJECT pobj);
	void Enhead(LPSAFEWALL_OBJECT pobj);
	char* Encode(DWORD version, char* buffer, ULONG lenght,
		LARGE_INTEGER* keyOffset, SWID* privateKey, SWID* publicKey);
	char* Decode(DWORD version, char* buffer, ULONG lenght,
		LARGE_INTEGER* keyOffset, SWID* privateKey, SWID* publicKey);

	int CreateSafeWallFilePath(IN PUNICODE_STRING srcFilePath, OUT PUNICODE_STRING newFilePath);
	NTSTATUS GetMyDeviceObjectByFilePath(IN PUNICODE_STRING FilePath, OUT PDEVICE_OBJECT* DeviceObject);
	NTSTATUS SafeWallReplaceFile(HANDLE srcFile, PFILE_OBJECT srcFileObject, POBJECT_ATTRIBUTES srcFileAttributes,
		HANDLE newFile, PFILE_OBJECT newFileObject, POBJECT_ATTRIBUTES newFileAttributes, PDEVICE_OBJECT pDeviceObject);
	BOOLEAN GetSafeWallByFilePath(IN PUNICODE_STRING FilePath,
		IN PDEVICE_OBJECT DeviceObject,
		OUT LPSAFEWALL_OBJECT SafeWall);

	BOOLEAN GetSafeWallByFileHandle(IN HANDLE FileHandle, IN PFILE_OBJECT FileObject, 
		IN PDEVICE_OBJECT DeviceObject, OUT LPSAFEWALL_OBJECT SafeWall);
#ifdef __cplusplus
}
#endif

#endif